package com.storlead.shiro.config;

import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.subject.Subject;
import org.apache.shiro.web.filter.AccessControlFilter;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

/**
 * @Author: Timo
 * @Date: 2019/2/14 17:30
 * @Description: 类用途：
 */
@Slf4j
public class KickoutSessionFilter extends AccessControlFilter {

    @Override
    protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) throws Exception {
        log.info("KickoutSessionFilter.isAccessAllowed");
        Subject subject = getSubject(request, response);
        String url = getPathWithinApplication(request);
        log.info("url->{}",url);
        return subject.isPermitted(url);
    }

    @Override
    protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws Exception {
        log.info("KickoutSessionFilter.onAccessDenied");
        return false;
    }
}
